package net.hmr_radio.hmrbot.controller.login;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;

import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

public class ByGoogleController extends Controller {

    private UserService userService = UserServiceFactory.getUserService();

    @Override
    public Navigation run() throws Exception {
        if (userService.isUserLoggedIn()) {
            return forward("/login/byGoogleSuccess");
        }
        return redirect(userService.createLoginURL("/login/byGoogleSuccess"));
    }
}
